function H=get_anglWeight(theta,pctg)
%computes weights to smooth the outer angles in the sinograph to reduce artifacts
%
%example of usage:
% p=data of sinograph
% W=get_anglWeight(angles);
% for i=1:size(p,2)
%     p(:,i)=p(:,i)*W(i);    
% end
%
%pct of fading area; 1= complete fading 0=No fading
%author: Sebastian Schmelcher version: 2012-04-23

if(nargin<2)
    pctg=.3;
end
t_min=min(theta);
t_max=max(theta);
rad=t_max-t_min;
orientation=(t_min+t_max)/2;

theta=abs(theta-orientation);

fad_r=pctg*rad/2;
fad_x=orientation+(1-pctg)*rad/2;
H=zeros(1,length(theta));
H=H+(theta<=(fad_x));
H=H+(theta>(fad_x)).*(exp(-fad_r^2./(fad_r^2-(theta-fad_x).^2)))/exp(-1);
H(isnan(H))=0;
H(isinf(H))=0;